<?php
	session_start();
?>
<html>
	<head></head>
	<body>
		<?php
			include("sql.php");
			echo "<h2 align=center>Listado del Cat&aacute;logo de Libros</h2>";
			$conexion=Conectarse();			
			$resultado=mysql_query("SELECT * FROM libros",$conexion);
			echo "<TABLE align=center BORDER=\"1\" CELLSPACING=\"1\" CELLPADDING=\"1\">";
				echo "<TR>";
					echo "<TD align=center><b>&nbsp;Autor&nbsp;</b></TD>";
					echo "<TD align=center><b>&nbsp;T&iacute;tulo&nbsp;</b></TD>";
					echo "<TD align=center><b>&nbsp;Editorial&nbsp;</b></TD>";
					echo "<TD align=center><b>&nbsp;A&ntilde;o&nbsp;</b></TD>";
					echo "<TD align=center><b>&nbsp;G&eacute;nero&nbsp;</b></TD>";
					echo "<TD align=center><b>&nbsp;Portada&nbsp;</b></TD>";
					echo "<TD align=center><b>&nbsp;Venta</b></TD>";
					echo "<TD align=center><b>&nbsp;Precio</b></TD>";
					echo "<TD align=center><b>&nbsp;Ficha t&eacute;cnica&nbsp;</b></TD>";
				echo "</TR>";
				while ($fila=mysql_fetch_array($resultado)){
					echo "<TR>";
						echo "<TD>&nbsp;".$fila["autor"]."</TD>";
						echo "<TD>&nbsp;".$fila["titulo"]."</TD>";
						echo "<TD>&nbsp;".$fila["editorial"]."</TD>";
						echo "<TD>&nbsp;".$fila["ano"]."</TD>";
						echo "<TD>&nbsp;".$fila["genero"]."</TD>";
						echo "<td align=\"center\"><a target=\'_blank\' href=\"../img/$fila[imagen]\"><img src=\"../img/$fila[imagen]\" width=50 height=50></a></td>";
						echo "<TD align=\"center\">&nbsp;".$fila["ejemplares"]."</TD>";
						echo "<TD align=\"right\">&nbsp;".$fila["precio"]."</TD>";
						echo "<td align=\"center\"><a target=\'_blank\' href=\"../docs/$fila[titulo].pdf\">Sinopsis</a></td>";
					echo "</TR>";
				}
			echo "</table>";
			if (empty($_SESSION['usuario'])){
				echo "<br>";
				echo "<div align=center>";
					echo "<a href=\"buscar_libros.php\">Nueva b&uacute;squeda</a>";
				echo "</div>";
				echo "<br>";
				echo "<p align=center>Para comprar libros debe registrarse ==> <a href='alta_cliente.php'>Registrase</a></p><br>";
				session_destroy();
			}
			mysql_close($conexion);
		?>
	</body>
</html>